package tech.waterism.utils.moea;


import tech.waterism.constant.DispatchConstants;
import tech.waterism.constant.StationTypeConstans;
import tech.waterism.dto.*;

import java.util.Date;


public class DispatchUtils {
    public static void setNatureFlowwaySingle(TopoObjectDto topoObjectDto, Date fymdh) {
        if (!StationTypeConstans.RSVR_SET.contains(topoObjectDto.getFpIndex().getOutcd())) {
            return;
        }
        for (ForecastDataDto datum : topoObjectDto.getFpIndex().getData()) {
            if (datum.getDt().after(fymdh)) {
                datum.setFlowWay(DispatchConstants.FLOW_WAY_GIVEN_BY_NATUREINFLOW);
            }
        }
    }

    public static void setCurrentFlowwaySingle(TopoObjectDto topoObjectDto, Date fymdh) {
        if (!StationTypeConstans.RSVR_SET.contains(topoObjectDto.getFpIndex().getOutcd())) {
            return;
        }
        Double qout = null;
        for (ForecastDataDto datum : topoObjectDto.getFpIndex().getData()) {
            if (datum.getDt().equals(fymdh)) {
                qout = datum.getQOut();
            }
            if (datum.getDt().after(fymdh)) {
                datum.setQOut(qout);
                datum.setFlowWay(DispatchConstants.FLOW_WAY_BALANCE_BY_OUTFLOW);
            }
        }
    }

    public static void setQoutZeroSingle(TopoObjectDto topoObjectDto, Date fymdh) {
        for (ForecastDataDto datum : topoObjectDto.getFpIndex().getData()) {
            if (datum.getDt().after(fymdh)) {
                datum.setQOut(0.0);
                datum.setFlowWay(DispatchConstants.FLOW_WAY_BALANCE_BY_OUTFLOW);
            }
        }
    }

    public static void setQoutAssignSingle(TopoObjectDto topoObjectDto, Date fymdh) {
        for (ForecastDataDto datum : topoObjectDto.getFpIndex().getData()) {
            if (datum.getDt().after(fymdh)) {
                datum.setFlowWay(DispatchConstants.FLOW_WAY_BALANCE_BY_OUTFLOW);
            }
        }
    }
}

